package function

import (
	"database/sql"
	"fmt"
	_ "github.com/lib/pq"
)

type company struct {
	id        int
	name      string
	age       int
	address   string
	salary    int
	join_date string
}

func Query(db *sql.DB) {

	sqlStatement1 := `SELECT * FROM company WHERE id=$1;`
	var result company
	row := db.QueryRow(sqlStatement1, 4)
	err := row.Scan(&result.id, &result.name, &result.age, &result.address, &result.salary, &result.join_date)
	switch err {
	case sql.ErrNoRows:
		fmt.Println("No rows were returned!")
		return
	case nil:
		fmt.Println(result)
	default:
		panic(err)
	}
}
